script_enemy_main{

let effect1=0;
let object1=[];
let timer1=[];
let angle1=[];

let effect2=0;
let object2=[];
let timer2=[];

let startpos=rand(0,360);
let phase=0;

let character="Haruna";
let cutin=character;
let dispelled=0;
let spellcards=1;
let spellcardnumber=35;
let damagerate=10;
let outfit=1;
outfit=(128*outfit)-128;
let usespell=0;
let bgfade=0;
let frame=0;
let time=0;
let miny=GetClipMinY; let maxy=GetClipMaxY; let minx=GetClipMinX; let maxx=GetClipMaxX;
let cx=GetCenterX; let cy=GetCenterY;

let SEshot1=("script\SoundEffects\shots3.wav");
let SEshot2=("script\SoundEffects\shotb1.wav");

let GReffect1=("\script\Images\OtherEffects\Pulse.png");

let BG1=("\script\Images\BackgroundLayers\Haruna2.png");
let BG2=("\script\Images\BackgroundLayers\Haruna3a.png");
let GRboss=("\script\Images\CharacterSprites\Haruna.png");

#include_function "script/Functions/SetSpellcardCommonData.txt";
#include_function "script/Functions/SpellcardNameLoad.txt";
#include_function "script/Functions/HealthBarLoad.txt";
#include_function "script/Functions/CutInLoad.txt";

@Initialize{
	LoadUserShotData("script\shots\ShotsHaruna1.txt");

	LoadSE("\script\SoundEffects\shotb7.wav");

	LoadGraphic("\script\Images\BackgroundLayers\Haruna2.png");
	LoadGraphic("\script\Images\BackgroundLayers\Haruna3a.png");
	LoadGraphic("\script\Images\OtherEffects\Pulse.png");
	LoadGraphic("\script\Images\CharacterSprites\Haruna.png");
	
	SetScore(300000);
	SetLife(300);
	SetTimer(50);
	SetInvincibility(120);
	SetDamageRate(10,10);
	SetEnemyMarker(true);
	MagicCircle(true);
	#include_function "script/Functions/Focus.txt";
	Focus(character);
	SetEffectForZeroLife(60,100,1);
	SetMovePosition02(cx,cy,50);
}
	
@MainLoop{

SetCollisionA(GetX,GetY,16);
SetCollisionB(GetX,GetY,16);
SetShotAutoDeleteClip(32,32,32,32);

Weakness(character);
#include_function "script/Functions/Weakness.txt";
if(GetCommonData("BombOn")==0){ damagerate=10; }
if(GetCommonData("BombOn")==1){ damagerate=5; }
SetDamageRate(damagerate*weaken,damagerate*weaken);

let difficulty="";
if(GetCommonDataDefault("Difficulty",2)==1){ difficulty="Easy"; }
if(GetCommonDataDefault("Difficulty",2)==2){ difficulty="Normal"; }
if(GetCommonDataDefault("Difficulty",2)==3){ difficulty="Hard"; }
if(GetCommonDataDefault("Difficulty",2)==4){ difficulty="Lunatic"; }

SpellcardName("Theory of Mind [Empathic Distress] ("~difficulty~")",spellcardnumber); 
HealthBar();
Portrait(cutin,1);


if(frame>=40 && time%5==0 && time>=60 && GetLife>0){
let shot1=0;
let angle=time+startpos;
SetShotColor(295-frame,295-frame,295-frame);
	loop(2){
	CreateShotA(shot1,GetX,GetY-20,0);
	SetShotDataA(shot1,0,2.5+1*cos(time*1.1),angle,0,-0.03,0,32);
	SetShotDirectionType(PLAYER);
	SetShotDataA(shot1,150,0,0,0,0.1,1.5,25);
	SetShotDirectionType(ABSOLUTE);
	FireShot(shot1);
	angle+=360/2;
	}
usespell=150;
PlaySE(SEshot1);
}
if(frame==150){
SetShotColor(255,255,255);
let a=rand(0,360);
	loop(8){
	CreateShot02(GetX,GetY,0,a,0.08,1.5,11,0);
	CreateShot02(GetX,GetY,0,a,0.08,1.5,50,0);
	a+=360/8;
	}
PlaySE(SEshot2);
frame=0;
}


if(time%10==0 && GetLife>0){
let choice1=rand_int(0,3);
let dir1=choice1*90;
let rad1=rand(0,360);
	effect1=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(effect1,GetX+30*cos(rad1),GetY+30*sin(rad1));
	ObjEffect_SetScale(effect1,2,2);
	Obj_SetAngle(effect1,dir1); Obj_SetSpeed(effect1,4);
	ObjEffect_SetLayer(effect1,1); ObjEffect_SetTexture(effect1,GReffect1); ObjEffect_SetRenderState(effect1,ADD);
	ObjEffect_SetPrimitiveType(effect1,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(effect1,4);
	ObjEffect_SetVertexXY(effect1,0,-7.5,-7.5); ObjEffect_SetVertexUV(effect1,0,0,0);
	ObjEffect_SetVertexXY(effect1,1,7.5,-7.5); ObjEffect_SetVertexUV(effect1,1,15,0);
	ObjEffect_SetVertexXY(effect1,2,-7.5,7.5); ObjEffect_SetVertexUV(effect1,2,0,15);
	ObjEffect_SetVertexXY(effect1,3,7.5,7.5); ObjEffect_SetVertexUV(effect1,3,15,15);
	ObjEffect_SetVertexColor(effect1,0,255,255,255,255); ObjEffect_SetVertexColor(effect1,1,255,255,255,255);
	ObjEffect_SetVertexColor(effect1,2,255,255,255,255); ObjEffect_SetVertexColor(effect1,3,255,255,255,255);
	object1=object1~[effect1];
	timer1=timer1~[effect1];
	timer1[length(object1)-1]=0;
	angle1=angle1~[effect1];
	angle1[length(object1)-1]=dir1;
}

if(time>=0){
let i=0;
	while(i<length(object1)){
		if(Obj_BeDeleted(object1[i])){
		object1=erase(object1,i); timer1=erase(timer1,i); i--;
		}
		else{
		timer1[i]=timer1[i]+1;
			if(timer1[i]%5==0){
			let choice1=rand_int(0,2);
			let dir1=0;
			if(choice1==0){ dir1=-90; }
			if(choice1==1){ dir1=90; }
			if(choice1==2){ dir1=0; }
			Obj_SetAngle(object1[i],Obj_GetAngle(object1[i])+dir1);
			ObjEffect_SetAngle(object1[i],0,0,Obj_GetAngle(object1[i]));
			}
		ObjEffect_SetScale(object1[i],1-timer1[i]/60,1-timer1[i]/60);
			if(timer1[i]>=20){ Obj_Delete(object1[i]); }

		effect2=(Obj_Create(OBJ_EFFECT));
		Obj_SetPosition(effect2,Obj_GetX(object1[i]),Obj_GetY(object1[i]));
		ObjEffect_SetScale(effect2,1,1);
		Obj_SetAngle(effect2,0); Obj_SetSpeed(effect2,0);
		ObjEffect_SetLayer(effect2,1); ObjEffect_SetTexture(effect2,GReffect1); ObjEffect_SetRenderState(effect2,ADD);
		ObjEffect_SetPrimitiveType(effect2,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(effect2,4);
		ObjEffect_SetVertexXY(effect2,0,-5,-5); ObjEffect_SetVertexUV(effect2,0,0,0);
		ObjEffect_SetVertexXY(effect2,1,5,-5); ObjEffect_SetVertexUV(effect2,1,15,0);
		ObjEffect_SetVertexXY(effect2,2,-5,5); ObjEffect_SetVertexUV(effect2,2,0,15);
		ObjEffect_SetVertexXY(effect2,3,5,5); ObjEffect_SetVertexUV(effect2,3,15,15);
		ObjEffect_SetVertexColor(effect2,0,255,255,255,255); ObjEffect_SetVertexColor(effect2,1,255,255,255,255);
		ObjEffect_SetVertexColor(effect2,2,255,255,255,255); ObjEffect_SetVertexColor(effect2,3,255,255,255,255);
		object2=object2~[effect2];
		timer2=timer2~[effect2];
		timer2[length(object2)-1]=0;
		}
	i++;
	}
}

let i=0;
while(i<length(object2)){
	if(Obj_BeDeleted(object2[i])){
	object2=erase(object2,i); timer2=erase(timer2,i); i--;
	}
	else{
	timer2[i]=timer2[i]+1;
	ObjEffect_SetScale(object2[i],1-timer2[i]/50,1-timer2[i]/50);
	if(timer2[i]>=50){ Obj_Delete(object2[i]); }
	}
i++;
}


time++; frame++;
if(usespell>0){ usespell--; } if(usespell<0){ usespell++; }
SetCommonData("Boss1X",GetX); SetCommonData("Boss1Y",GetY);

#include_function "script/Functions/SpellcardName.txt";
#include_function "script/Functions/HealthBar.txt";
#include_function "script/Functions/CutIn.txt";
}

@BackGround{
	if(bgfade<255){ bgfade+=5; }

	SetGraphicRect(0-time,0,300-time,300);
	SetGraphicScale(1.75,1.75);
	SetTexture(BG1);
	SetAlpha(bgfade);
	SetColor(128+127*cos((time+0)),128+127*cos((time+120)),128+127*cos((time+240)));
	SetRenderState(ALPHA);
	SetGraphicAngle(0,0,-time/2.5);
	DrawGraphic(cx,cy);
	
	SetGraphicRect(0+time,0,600+time,600);
	SetGraphicScale(1,1);
	SetTexture(BG2);
	SetAlpha(bgfade);
	SetColor(255,255,255);
	SetRenderState(ALPHA);
	SetGraphicAngle(0,0,0);
	DrawGraphic(cx,cy);
}

@DrawLoop{
	SetGraphicScale(1,1);
	SetTexture(GRboss);
	SetGraphicAngle(0,0,0);
	SetColor(255,255,255);
	SetRenderState(ALPHA);

	if(usespell>=1){ SetGraphicRect(384,outfit,512,outfit+128); }
	if(usespell<=-1){ SetGraphicRect(512,outfit,640,outfit+128); }
	if(usespell==0){
		if(GetSpeedX<=0.5 && GetSpeedX>=-0.5){ SetGraphicRect(0,outfit,128,outfit+128); }
		else if(GetSpeedX<-0.5){ SetGraphicRect(128,outfit,256,outfit+128); }
		else if(GetSpeedX>0.5){ SetGraphicRect(256,outfit,384,outfit+128); }
	}
	DrawGraphic(GetX,GetY);
}

@Finalize{
	SetCommonData("Conversation",1);
	NewPointData(spellcardnumber,GetCommonData("Difficulty"));
	#include_function "script/Functions/Main Menu/SpellcardDataAndPoints.txt";
}

}